Fix inline export forwarder generation regression #23126
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To explain what was happening and what the issue was:
Minimalisation:
would fail retyping in the inlining phase.
During typer, because we were exporting contents of
Internal
, the compiler created forwarders (in Namer.addForwarder) for methods chosen in the export. The forwarders looked like this:While creating them, the compiler would also try to type them. Because those forwarder methods were inline, the compiler would call PrepareInlineable.makeInlineable on them. That method would transform rhs of the forwarder method, to make sure it does not reference any private methods/objects. Since
Internal
is private (and referenced in both exported methods, notably in brew with rhs jam.Internal.brew(config)), an accessor inline$Internal was created, and the forwarder method contents remapped.Then, during inlining in the inline phase, the ReTyper was not able to type
jam.inline$internal.brew(config)
, withjam.inline$internal.brew
being typed asNothing => Unit
(likely having remapped the argument to Nothing in an asSeenFrom, after deciding that the prefix is not stable).But none of this happened when I created those forwarders and accessors manually. After some digging it turned out that the
inline$internal
accessor method was typed asTypeRef(ThisType(TypeRef(NoPrefix,module class jam)),module class internal$))
, but the manually created one was aTermRef(ThisType(TypeRef(NoPrefix,module class jam)), object Internal)
. It seems like the first one has an unstable prefix, so its denotation is not typed correctly, leading to the issue.Fixes #22593